package ua.org.enginer.controls
{
	import flash.display.Sprite;
	
	import mx.collections.IList;
	import mx.controls.DataGrid;

	public class RowColoringDataGrid extends DataGrid
	{
		public function RowColoringDataGrid()
		{
			super();
		}
		
		[Bindable]
		public var rowColoringFunction:Function;
		
		override protected function drawRowBackground(s:Sprite, rowIndex:int, y:Number, height:Number, color:uint, dataIndex:int):void {
			if (rowColoringFunction != null && IList(dataProvider).length > dataIndex) {
				color = rowColoringFunction(IList(dataProvider).getItemAt(dataIndex), dataIndex, color);
			}
			super.drawRowBackground(s, rowIndex, y, height, color, dataIndex);
		}
	}
}